<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>微观世界</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="/pics/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="<?php echo SCScabish::core('url')->root?>/public/js/humane/themes.css" type="text/css" media="screen" />
    <script src="<?php echo SCScabish::core('url')->create('server/side')?>" type="text/javascript"></script>
    <script src="<?php echo SCScabish::core('url')->root?>/public/js/jquery.js" type="text/javascript"></script>
    <script src="<?php echo SCScabish::core('url')->root?>/public/js/humane/humane.min.js" type="text/javascript"></script>
    <style>
		body{font-family:"\5FAE\8F6F\96C5\9ED1",Arial,Helvetica,sans-serif;color:#fff;background:#838B8B;text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);}
		input[type="text"],input[type="password"] { padding: 10px;margin-bottom:5px;font-size:20px;letter-spacing:0px;color:#aaa;}
		textarea { width: 750px; height: 275px; padding: 10px;margin:5px 0;}
		label { color: #ff5400; }
		input, textarea { border:1px solid #ddd;resize:none; font-family:"\5FAE\8F6F\96C5\9ED1",Arial,Helvetica,sans-serif; color: #4b4b4b; font-size: 14px;}
		input:focus, textarea:focus { border: 1px solid #ddd; background-color: rgba(255, 255, 255, 1); box-shadow:0 0 5px #000}
		
		.button{display:inline-block;background:#9ACD0F;color:#fff;margin:0;height: 40px;line-height: 40px;outline: medium none;text-align: center;padding:0 15px;font-size:20px;}
		.button:focus{color: #fff; background-color: #6D9906;box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.6); outline:none;text-decoration:none;}
		.button:active{position:relative;top:1px;}
	</style>
</head>
<body>
	<div class="my-login">
		<div class="my-logo" style="margin-bottom:15px;" >
			<img src="/pics/LOGO-L.png" title="微观世界" alt=""/>
		</div>
		<div class="clear"></div>
		<div id="next_step" style="display:none; margin:200px 0 0 200px;">
			<div style="font-size:40px;"><img id="avatar" src="" style="vertical-align:bottom;margin-right:10px;border-radius:1px;"/>欢迎你，<span id="nickname"></span></div>
			<div class="my-txtmo">
				<div style="margin:20px 0;font-size:18px;">绑定微观账号，开启新的旅程<!-- 检测email，如果没有该条记录则自动创建 --></div>
				<div class="share-list">
					<form id="data_form" action="" method="post" onsubmit="return false;">
						<input type="text" id="email" name="email" placeholder="邮箱" tabindex="1" style="margin-right:10px;width:240px;" />
						<input type="password" id="password" name="password" value="" placeholder="密码" tabindex="2" style="width:240px;" /><br/>
						<input type="hidden" name="vendor" value="<?php echo $vendor?>" />
						<input type="submit" value="下一步" class="button" style="margin-top:10px;"/>
					</form>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
$(function() {
	
	// 设置背景图
	$.get(SCABISH.host+'/api/background', function(response) {
		//response = 'http://l.bst.126.net/pub/design/6598157183656169032.jpg'
		document.body.style.background = '#838B8B url('+response+') no-repeat fixed top';
	});

	var rebind = function() {
		window.location.href = SCABISH.host + '/connect/authorize/vendor/<?php echo $vendor?>';
	};

	var showError = function(msg) {
		var jacked = humane.create({baseCls: 'humane-jackedup'});
		jacked.error = jacked.spawn({addnCls: 'humane-jackedup-error'});
		jacked.error(msg);
	};
	
	$('#email').focus();
	var $form = $('#data_form');
	
	$.get(SCABISH.host+'/api/openInfo/vendor/<?php echo $vendor?>', function(response) {
		if(SCABISH.isOk(response)) {
			var data = SCABISH.obtain(response);
			<?php if($vendor == 'tencent') { ?>
			$('#nickname').text(data.nickname);
			$('#avatar').attr('src', data.figureurl_1);
			<?php } elseif($vendor == 'weibo') { ?>
			
			<?php } ?>
			$('#next_step').fadeIn();
		} else { // openid失效，重新绑定
			rebind();
		}
		
	});

	$form.submit(function() {
		if($.trim($('#email').val()) == '') {
			showError('别忘记了输入你常用的邮箱哦:)'); 
			$('#email').val('').focus();
			return false;
		}
		if(!/\w+@\w+\.\w{2,3}/.test($.trim($('#email').val()))) {
			showError('邮箱格式有点小问题哦亲！');
			$('#email').focus();
			return false;
		}
		if($('#password').val() == '') {
			showError('还差一步，给自己设定一个彪悍的密码吧');
			$('#password').focus();
			return false;
		}
		var url = '<?php echo SCScabish::core('url')->create('connect/doBind')?>';
		$.post(url, $(this).serialize(), function(response) {
			if(SCABISH.isOk(response)) {
				window.location.href = SCABISH.host+'/home';
			} else {
				error = SCABISH.obtain(response);
				if(error == 'OPEN_ID_EXPIRED') { // openid失效，重新绑定
					rebind();
				} else {
					showError(error);
				}
			}
		});
		return false;
	});
});
</script>
</body>

</html>